package com.lm.paymentadmin.util;

import java.util.Random;

/**
 * @author liuming
 */
public class RandomUtil {

    public static String getRandom(){
        String str = "0,1,2,3,4,5,6,7,8,9,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z";

        //将字符串以,分割
        String str2[] = str.split(",");

        //创建Random类的对象rand
        Random rand = new Random();

        int index = 0;

        //创建内容为空字符串对象randStr
        String randStr = "";

        //在0到str2.length-1生成一个伪随机数赋值给index
        for (int i=0; i<4; ++i){
            index = rand.nextInt(str2.length-1);
            //将对应索引的数组与randStr的变量值相连接
            randStr += str2[index];
        }
        return randStr;

    }
}
